package soulkun.library.custom.activity

import android.app.Activity
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_xy.*
import soulkun.library.component.BaseActivity
import soulkun.library.utils.R
import soulkun.library.utils.screen.ScreenUtils


class XyActivity : BaseActivity(true) {

    companion object{
        /**
         * type 1 用户协议  2 隐私政策
         */
        fun startIntent(activity: Activity, type: Int, app: String, fileUrl: String) {
            val intent = Intent(activity, XyActivity::class.java)
            intent.putExtra("type", type)
            intent.putExtra("app", app)
            intent.putExtra("fileUrl", fileUrl)
            activity.startActivity(intent)
        }
    }

    override fun setLayout(): Int {
        return R.layout.activity_xy
    }

    override fun initIntent() {
    }

    override fun initView() {
        val type = intent.getIntExtra("type", 0)
        val app = intent.getStringExtra("app")
        val fileUrl = intent.getStringExtra("fileUrl")
        ScreenUtils.setBlackStatusText(this)
        when (type) {
            1 -> {
                tv_xy_title.text = "用户协议"
            }
            2 -> {
                tv_xy_title.text = "隐私政策"
            }
        }
        tv_xy_app_title.text = "$app(以下称'本应用')"
        if (fileUrl != null) {
            web_view_xy.loadUrl(fileUrl)
            web_view_xy.setBackgroundColor(0)
        }
    }

    override fun initData() {
    }

    override fun initListener() {
        tv_xy_back.setOnClickListener { finish() }
    }


}